/**
 * Copyright (c) 2008,中企动力华南研发中心 All rights reserved.
 */
package com.ce.util;

import java.util.HashMap;
import java.util.Map;

/**
 * 逻辑、功能相关描述:上传工具类辅助类
 *
 * @author 申定溪 编写日期：2008-1-21
 */


public class MultipartRequest {
	public MultipartRequest() {
	}

	private Map parameterMap;

	public static MultipartRequest newInstance(Map paraMap) {
		MultipartRequest multi = new MultipartRequest();
		multi.setParameterMap((Map)paraMap.get("paraType"));
		return multi;
	}

	public Map getParameterMap() {
		return this.parameterMap;
	}


	public void setParameterMap(Map parameterMap) {
		this.parameterMap = parameterMap;
	}




	/**
	 * Function:overwrite HttpServletRequest.getParameter(String[]) method.
	 * @param String[] key
	 * @return String[]
	 * Create author:xuhaidui
	 * Create on:2008-1-21
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
    public String[] getParameters(String[] key) {
    	HashMap paraMap =(HashMap) getParameterMap();

    	String[] vs=null;

    	for  (int i=0;i<key.length;i++) {
    	    String temp= (String) paraMap.get(key[i]);
    	    vs[i]=temp;
    	}

        if (vs != null && vs.length > 0) {
            return vs;
        }

        return null;
    }


	/**
	 * Function:overwrite HttpServletRequest.getParameter(String) method.
	 * @param HashMap hm
	 * @param String[] key
	 * @return String
	 * Create author:xuhaidui
	 * Create on:2008-1-21
	 * Edit author:
	 * Edit on:
	 * Why:
	 */
    public String getParameter(HashMap hM, String key) {
    	HashMap paraMap =(HashMap) getParameterMap();

    	String[] vs = (String[]) paraMap.get(key);

        if (vs != null && vs.length > 0){
            return vs[0];
        }
        return null;
    }


}
